#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry

import sys
import os
import logging
from SceneCheckTool.checkScript.CheckBase import CheckBase

try:
    import maya.cmds as cmds
    import pymel.core as pm
    import jarryLibs.mayakit.MayaUtils as mu
    reload(mu)
except:
    pass

logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


class ELSMeshNameRule(CheckBase):
    def __init__(self):
        super(ELSMeshNameRule, self).__init__()
        pass

    def init_file(self):
        import elsLibs.AssetInfoFromFile as elsaif
        reload(elsaif)
        current_file = mu.sceneName()
        aif = elsaif.AssetInfoFromFile(current_file)
        self.asset_name = aif.get_name
        self.shortType = aif.get_shortType
        self.step = aif.get_step

    def check(self):
        current_file = mu.sceneName()

        if not current_file:
            result_log = u'Error: 当前文件未保存!'
            return result_log
        try:
            self.init_file()
        except:
            result_log = u'Error:当前文件不符合ELS项目资产文件命名规则'
            return result_log

        result_proc = mu.check_mesh_name_rule(self.asset_name, 'msh')
        if result_proc:
            result_log = u'Error:%s\n' % result_proc
        else:
            result_log = u'Succeed:没有问题\n'

        return result_log

    def fix(self):
        pass
